home *** CD-ROM | disk | FTP | other *** search
/ Creative Computers / Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso / commercial / inovatronics / edgedemo / edgeeditor / rexx / menu_cmdshell.edge < prev    next >
Text File  |  1994-11-17  |  3KB  |  150 lines

  1.  
  2. /*
  3. ** $VER: CmdShell.edge 1.10 (Friday 08-Apr-94 10:37:24)
  4. **
  5. ** Edge's command shell
  6. **
  7. ** Written by Thomas liljetoft
  8. */
  9.  
  10.  
  11. options results
  12. options failat 100
  13.  
  14. /* get the name of the global port */
  15. 'get' g.devname rv edgehost
  16. address value edgehost
  17.  
  18. /* are we already running */
  19. 'set' g.commandshellstatus Active
  20. if result = "ACTIVE" then
  21.     do
  22.     'requestchoice' '"It appears that you already have a command-shell running.\010Do you wish to start this one anyway?"'
  23.     if RC ~= 0 then exit(0)
  24.     end
  25.  
  26. call open("stdin","console:",'R')
  27. call open("stdout","console:",'W')
  28. call writech('stdout',' ')
  29.  
  30. /* get users prefered text font */
  31. 'get' f.textfont
  32. parse var result fontname','fontsize','
  33. address command setfont fontname fontsize
  34.  
  35. say 'Enter commands, "Q" to exit, "?" for help.'
  36.  
  37. /*    loop until user exits */
  38.  
  39. mainloop:
  40.  
  41. signal on break_f
  42.  
  43. /*
  44. ** NOTE: ctrl f will break the command shell without trying to reset F31.
  45. */
  46.  
  47. signal on break_c
  48. signal on break_d
  49. signal on break_e
  50. signal on halt
  51. signal on ioerr
  52. signal on syntax
  53.  
  54. do forever
  55.  
  56.     call writech('stdout',''address()'> ')
  57.     cmd = readch('stdin',5000)
  58.  
  59.     select
  60.  
  61.         /* time to quit? */
  62.         when (length(cmd) = 2 & upper(left(cmd,1)) = "Q")    then do
  63.             leave
  64.       end
  65.  
  66.         /* need some help? */
  67.         when (length(cmd) = 2 & left(cmd,1) = "?") then do
  68.             say 'Enter "<command> ?" to obtain a command''s template.'
  69.             say 'Enter "HELP <command>" to obtain more help on a command.'
  70.             say 'Enter "Q" to exit command shell.'
  71.             say 'Enter "REXX <command>" to execute rexx commands.'
  72.       end
  73.  
  74.         /* do nothing on empty lines, e.g. only one character == 'return key' */
  75.         when (length(cmd) = 1) then do
  76.             'Nop'
  77.         end
  78.  
  79.         /* ctrl \ or closegadget return a null command */
  80.         when (cmd = "") then do
  81.             'closerexxio'
  82.             leave
  83.         end
  84.  
  85.         /* whatsinaline */
  86.         otherwise do
  87.  
  88.             /* if the commandstring starts with "rexx " interpret it as a rexx
  89.                 instruction instead of as an Edge command */
  90.             if upper(left(cmd,5)) = "REXX " then do
  91.                 interpret right(cmd,length(cmd) - 5)
  92.             end
  93.  
  94.             else do
  95.                 /* execute the command string, but first remove the NL character */
  96.                 left(cmd,length(cmd) - 1)
  97.             
  98.                 /* if ok show the result, if any */
  99.                 if RC == 0 then do
  100.                     if result ~= "RESULT" then say result
  101.                 end
  102.  
  103.                 else do
  104.                     say "*** Edge Error : "EDGEERROR" - "EDGEERRORSTRING
  105.                 end
  106.             end
  107.             
  108.       end
  109.  
  110.     end
  111. end
  112.  
  113. 'set' g.commandshellstatus
  114. exit(0)
  115.  
  116. /* here comes the signal handler routines */
  117.  
  118. syntax:
  119.     say 'Oups....   'errortext(RC) 
  120.     signal mainloop
  121.  
  122. halt:
  123.     say 'Halted.'
  124.     'set' g.commandshellstatus
  125.     exit(0)
  126.  
  127. ioerr:
  128.     say 'IO error.'
  129.     signal mainloop
  130.  
  131. break_c:
  132.     say 'Break...'
  133.     'set' g.commandshellstatus
  134.     exit(0)
  135.  
  136. break_d:
  137.     say 'Break...'
  138.     'set' g.commandshellstatus
  139.     exit(0)
  140.  
  141. break_e:
  142.     say 'Break...'
  143.     'set' g.commandshellstatus
  144.     exit(0)
  145.  
  146. break_f:
  147.     say 'Break...'
  148.     exit(0)
  149.  
  150.